package com.cw.config;

import cn.hutool.jwt.JWTUtil;
import org.springframework.context.annotation.Configuration;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Nice_BernardShaw
 * @date 2023/3/25 22:18
 */
@Configuration
public class JwtConfig {
    public static Long getCurrentId(HttpServletRequest request){
        String authorizaion = request.getHeader("Authorization");
        Long currentId = Long.valueOf(JWTUtil.parseToken(authorizaion).getPayload("current_id").toString());
        return currentId;
    }
}
